# -*- coding: UTF-8 -*-
"""
Create by Louis on 2019/7/28-22:20
"""
# __author__ = "Louis"

import xlrd

class ReadExcel:
    def __init__(self,xpath):
        self.data = xlrd.open_workbook(xpath)
        self.table = self.data.sheet_by_index(0)
        self.list=[]
    def single_read_xlrd(self):
        for rowNum in range(self.table.nrows):
            rowVale = self.table.row_values(rowNum)
            r={
                "id":rowVale[0],
                "name":rowVale[1],
                "age":rowVale[2],
                "profession":rowVale[3],
                "worktime":rowVale[4]
            }
            self.list.append(r)
        return self.list[1:]

if __name__ == "__main__":
    a= ReadExcel('./excelfile/excelzhong.xlsx')
    for i,j in enumerate(a.single_read_xlrd()):
        print(str(i+1)+":"+str(j))


# class ReadExcels:
#     def __init__(self):
#         pass
#     def read_xlrd(self,**kwargs):
#         list=[]
#         for key in kwargs:
#             data = xlrd.open_workbook(kwargs[key])
#             table = data.sheet_by_index(0)
#             for rowNum in range(table.nrows):
#                     rowVale = table.row_values(rowNum)
#                     list.append(rowVale)
#         return list